<?php

namespace app\api\controller;

use app\common\controller\Api;
use think\Validate;
use \app\common\model\HomeworkCorrections as HomeworkCorrectionsModel;

/**
 * 作业批改接口
 */
class Homeworkcorrections extends Api
{

    /**
     * 作业批改列表
     * @var array
     */
    protected $noNeedRight = '*';

    protected $model = null;

    public function _initialize()
    {
        parent::_initialize();
        $this->model = new HomeworkCorrectionsModel();
    }
    
    /**
     * 查询作业批改表
     * @ApiTitle    (查询作业批改表)
     * @ApiMethod  (GET)
     * @ApiParams (name="student_id", type="int", required=true, description="学生ID")
     * @ApiParams (name="homework_id", type="int", required=true, description="作业ID")
     * @ApiReturnParams   (name="code", type="integer", required=true, sample="0")
     * @ApiReturnParams   (name="msg", type="string", required=true, sample="查询成功")
     * @ApiReturn   ({
          'code':'200',
          'msg':'查询成功',
          'time': "",
          'data': $row
        })
     */
    public function correctionsIndex()
    {
        $data = input('post.');
        $studentId = $data['student_id'];
        $homeworkId = $data['homework_id'];
        if (!$studentId || !$homeworkId || !Validate::is($studentId, 'number') || !Validate::is($homeworkId, 'number')){
            $this->error('参数错误');
        }

        $dis = [
            'student_id' => $studentId,
            'assignment_id' => $homeworkId,
        ];
        $row = $this->model->dataInfo($dis);
        $this->success('查询成功', $row);
    }
}